using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Caching;
using System.Linq;
using Oplaco.Core.BusinessLogicLayer;
using Oplaco.Core.Configuration;
using Oplaco.Core.DAL;


namespace Oplaco.Web.DTO
{
    /// <summary>
    /// Category Data Transfer Object
    /// </summary>
    public class CachedCategory : ICacheableDataTransferObject<CachedCategory>
    {
        #region members
        private DateTime _publishdate;
        #endregion

        #region Property
        public bool HasChilds { get { return (this.ChildCollection == null) ? false : true; } }
        public ICollection<CachedCategory> ChildCollection { get; set; }

        public int Id
        {
            get;
            set;
        }

        public int ParentId
        {
            get;
            set;
        }

        public int NumberOfActiveAds
        {
            get;
            set;
        }

        public int Rank
        {
            get;
            set;
        }

        public int MemberId
        {
            get;
            set;
        }

        public string Title
        {
            get;
            set;
        }

               
        /// <summary>
        /// TitleWithActiveCount ; concat of title and collection count, 
        /// left it in to comply to legacy code, should not be needed
        /// </summary>
        public string TitleWithActiveCount
        {
            get;
            set;
        }

        public string Url
        {
            get;
            set;
        }

        public DateTime PublishDate
        {
            get { return _publishdate; }
            set { _publishdate = value; }
        }
        #endregion

        public CachedCategory(string name, int id, int parentCategoryId, int numActiveAds, CachedCategoryCollection childs)
        {
            this.Title = name;
            this.Id = id;
            this.ParentId = parentCategoryId;
            this.NumberOfActiveAds = numActiveAds;
            this.TitleWithActiveCount = String.Format("{0} ({1})", name, numActiveAds);
            if(childs!=null)  this.ChildCollection = (ICollection<CachedCategory>)childs;
        }

        
    }

   
}